<template>
  <div class="app-container">
    <div class="head">
      <img src="@/assets/img/Layout/position.png" />
      <p class="see-block">配置新增</p>
    </div>
    <div class="view-container">
      <el-row class="status-title">
        <el-col class="mr20 width100">
          <el-button
            class="btn-success width100"
            type="primary"
            @click="submitForm()"
          >提交</el-button>
        </el-col>
      </el-row>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px" class="mt30">
        <el-row>
          <el-col :span="12">
            <el-form-item label="acctId:" prop="acctId">
              <el-input v-model="form.acctId" placeholder="请输入acctId" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="appId:" prop="appId">
              <el-input v-model="form.appId" placeholder="请输入appId" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="appSec:" prop="appSec">
              <el-input v-model="form.appSec" placeholder="请输入appSec" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="userName:" prop="userName">
              <el-input v-model="form.userName" placeholder="请输入userName" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="lcId:" prop="lcId">
              <el-input v-model="form.lcId" placeholder="请输入lcId" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="serverUrl:" prop="serverUrl">
              <el-input v-model="form.serverUrl" placeholder="请输入serverUrl" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
  </div>
</template>

<script>
import { k3cloudConfigAdd } from "@/api/system/k3cloudConfig/k3cloudConfig"
export default {
  name: "add",
  data(){
    return {
      form: {
        acctId: '',
        appId: '',
        appSec: '',
        userName: '',
        lcId: '',
        serverUrl: '',
      },
      // 表单校验
      rules: {
        acctId: [
          { required: true, message: "acctId不能为空", trigger: "blur" }
        ],
        appId: [
          { required: true, message: "appId不能为空", trigger: "blur" }
        ],
        appSec: [
          { required: true, message: "appSec不能为空", trigger: "blur" }
        ],
        userName: [
          { required: true, message: "userName不能为空", trigger: "blur" }
        ],
        lcId: [
          { required: true, message: "lcId不能为空", trigger: "blur" }
        ]
      }
    }
  },
  methods: {
    // 提交数据
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.$modal.loading("正在提交")
          k3cloudConfigAdd(this.form).then(res=> {
            if(res.code == 200){
              this.$tab.closeOpenPage({ path: "/k3cloudConfig/list" })
              this.$modal.msgSuccess("新增成功")
              this.$modal.closeLoading()
            }else{
              this.$modal.msgError(res.msg)
              this.$modal.closeLoading()
            }
          })
        }
      })
    }
  }
}
</script>